package com.dinadi.yidi.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.dinadi.yidi.R;
import com.dinadi.yidi.bean.LogisticsRequest;

import java.util.ArrayList;
import java.util.List;

/**
 * author: JiaYu.He
 * Date: 2017/7/13
 * Time: 10:58
 */
public class LogisticsAdapter extends BaseAdapter {
    private List<LogisticsRequest> mList = new ArrayList<>();
    private Context context;

    public LogisticsAdapter(Context context, List<LogisticsRequest> mList) {
        this.context = context;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.adapter_logistics_item, null); /**这个是评论的item列表*/
            viewHolder = new ViewHolder();
            viewHolder.logistics_context = (TextView) convertView.findViewById(R.id.logistics_context);
            viewHolder.logistics_time = (TextView) convertView.findViewById(R.id.logistics_time);
            viewHolder.address_icon_circle_selected = (ImageView) convertView.findViewById(R.id.address_icon_circle_selected);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.logistics_context.setText(mList.get(position).getContext());
        viewHolder.logistics_time.setText(mList.get(position).getTime());
   /*     if ((mList.get(position).toString()).equals("0")) {
            viewHolder.address_icon_circle_selected.setImageResource(R.drawable.address_icon_circle_selected);
            //   viewHolder.logistics_context.setTextColor(R.color.color_333333);
        } else {
            viewHolder.address_icon_circle_selected.setImageResource(R.drawable.address_icon_circle_default);
            //viewHolder.logistics_context.get
        }*/

        if (position == 0) {
            viewHolder.address_icon_circle_selected.setImageResource(R.drawable.address_icon_circle_selected);
            viewHolder.logistics_context.setTextColor(context.getResources().getColor(R.color.color_333333));
        } else {
            viewHolder.address_icon_circle_selected.setImageResource(R.drawable.address_icon_circle_default);
        }
        return convertView;
    }

    class ViewHolder {
        TextView logistics_context, logistics_time;
        ImageView address_icon_circle_selected;


    }
}
